<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>

    const obj = {
        name:"admin",
        age:18,
        sex:"男"
    }

    const target = new Proxy(obj, {
        get(origin, attr){
            console.log("访问了", origin, "对象的"+ attr +"属性")
            return origin[attr];
        },
        set(origin, attr, val){
            console.log(origin, "对象的"+ attr +"属性被修改成了" + val)
            origin[attr] = val;
        }
    })

    obj.msg = "hahahaah";

    console.log(target);

    target.name = "asd"
    target.age = 20
    target.sex

    target.sex = "男"
    target.age = 18

</script>
</html>